package com.example.DemoDataeaseExample.provider;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.net.URLClassLoader;
public class ExtendedJdbcClassLoader extends URLClassLoader {

    public ExtendedJdbcClassLoader(URL[] urls, ClassLoader parent) {
        super(urls, parent);
    }

    @Override
    protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException {
        try {
            // 尝试从父类加载器加载
            return super.loadClass(name, resolve);
        } catch (ClassNotFoundException e) {
            // 如果父类加载器无法加载，尝试从当前加载器加载
            return findClass(name);
        }
    }

    public void addFile(String path) throws IOException {
        addFile(new File(path));
    }

    public void addFile(File file) throws IOException {
        addURL(file.toURI().toURL());
    }
}